use modular_bitfield_msb::prelude::*;

#[bitfield]
#[derive(Debug, Clone, Copy)]
#[repr(u8)]
pub struct WindowDescriptor {
    exponent:B5,
    mantissa:B3,
}

impl WindowDescriptor {
    fn window_log(&self) -> u8 {
        self.exponent() + 10
    }

    fn window_base(&self) -> u64 {
        1u64 << self.window_log()
    }

    fn window_add(&self) -> u64 {
        (self.window_base() >> 3) * self.mantissa() as u64
    }

    pub fn window_size(&self) -> u64 {
        self.window_base() + self.window_add()
    }
}